#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int N, M, K, ans;
int mk[1010], cows[1010];
bool vis[1010];
vector<int> Map[1010];
void dfs(int x)
{
    vis[x] = 1;
    mk[x]++;
    for (int i = 0; i < Map[x].size(); i++)
    {
        if (!vis[Map[x][i]])
            dfs(Map[x][i]);
    }
}
int main()
{
    int x, y;
    cin >> K >> N >> M;
    for (int i = 1; i <= K; i++)
        cin >> cows[i];
    for (int i = 1; i <= M; i++)
    {
        cin >> x >> y;
        Map[x].push_back(y);
    }
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            vis[j] = 0;
        }
        dfs(cows[i]);
    }
    for (int i = 1; i <= N; i++)
    {
        if (mk[i] == K)
            ans++;
    }
    cout << ans;
    return 0;
}